<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ page import="com.gouwudai.gobbs.pojo.TbbsUserInfo"%>
<%@ include file="../common/common.jsp" %>
<%@ include file="user_pass2.jsp" %>
<%
int userId = ParamUtils.getIntParameter(request,"userId");

String friendLoginId = "";
if(userId>0)
{	
	IUserService userService = (IUserService)BeanManager.getBean("userService");
	TbbsUserInfo tbbsUserInfo = userService.load(userId);
	friendLoginId = tbbsUserInfo.getLoginId();
}
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><%=SYSTITLE%> - 添加好友</title>
<meta name="Keywords" content="<%=SYSMETAKEY%>" />
<meta name="Description" content="<%=SYSMETADESC%>" />
<%@ include file="../common/meta.inc" %>
<link rel="stylesheet" type="text/css" href="css/defaultStyle.css" >
<script language="javascript" src="${pageContext.request.contextPath}/scripts/common-validator.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/prototype.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/buffalo/buffalo.js"></script>
</head>
<body>
<%@ include file="../common/waiting.inc" %>
<SCRIPT language="javascript">

setStatus('<%=SYSTITLE%> - 添加好友');

function showMessage(flag)
{
	var divMessage = $("divMessage");
	if(flag)
	{
		divMessage.style.display = "";		
	}else{
		divMessage.style.display = "none";	
	}
}

var END_POINT="${pageContext.request.contextPath}/buffalo";
var buffalo = new Buffalo(END_POINT);

function doSubmit() 
{	
	form = document.theform;
	if(!validateForm(form))
		return false;
		
    var obj = {};    
    
	obj[Buffalo.BOCLASS] = "java.util.HashMap";	
	
	obj.userLoginId = "<%=LOGIN_ID%>";
	obj.userLoginIp = "<%=LOGIN_IP%>";
	obj.sendMessageFlag = getRadioValue("sendMessageFlag");
	obj.friendLoginIds = $F("friendLoginIds");
	obj.message = $F("message");
	
    buffalo.remoteCall("friendsServiceAjaxService.doAddFriend",[obj], function(reply) 
    {
        var ret = reply.getResult();
       	ajaxSubmit(ret,"您的请求已被发送！","");        
    });   
}

function validateForm(form)
{
	if(!sl_check(form.friendLoginIds,"朋友ID",200,1)) return false;
	return true;
}
</script>
<script language="javascript" type="text/javascript" src="template/scripts/topBar.js"></script>
<%@ include file="includes/userMenu.inc" %>
<DIV class="line"></DIV>
<DIV class="list_table_0"><%=HtmlConst.navMenu("user_take.jsp","我的工具箱")%>&gt;&gt;我的好友
&nbsp;&nbsp;[<b><a href="user_friends_add.jsp">添加好友</a></b>]&nbsp;&nbsp;[<a href="user_friends.jsp">好友列表</a>][<a href="user_friends_wait.jsp?friendType=1">准好友列表</a>]&nbsp;&nbsp;[<a href="user_friends_black.jsp?friendType=2">黑名单</a>]
</DIV>
<DIV class="line"></DIV>
<form name="theform" id="theform" method="post" onSubmit="return validateForm(this);">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tab">
<tr class="tab3">
  <td width="160" height="10"><strong>朋友ID</strong></td>
    <td><input name="friendLoginIds" type="text" id="friendLoginIds" value="<%=friendLoginId%>" size="50" />
      <div class="remark">多个朋友请用半角逗号( , )隔开,无效和已申请过的ID将被自动过滤<div></td>
    </tr>
<tr class="tab3">
  <td height="11"><strong>是否用通知朋友</strong></td>
<td>
<input id="sendMessageFlag" name="sendMessageFlag" type="radio" value="false" checked="checked" onclick="javascript:showMessage(false);"/>默认短消息通知
&nbsp;&nbsp;
<input id="sendMessageFlag" name="sendMessageFlag" type="radio" value="true"  onclick="javascript:showMessage(true);"/>自定义短消息通知朋友
<table align="center" id="divMessage" style="DISPLAY: none" cellpadding="1" cellspacing="1"  width="100%">
<tr><td>
<textarea name="message" cols="80" rows="6"></textarea>
</td></tr>
</table>
</td>
</tr>
<tr class="tab3">
  	<td height="22">&nbsp;</td>
    <td>
		<input name="btnSubmit" type="button" class="btn" id="btnSubmit" value="确定" onClick="javascript:doSubmit();"/>		
	</td>
    </tr>
</table>
</form>
<%=COPYRIGHTFOOT%>
<%@ include file="../common/foot.inc"%>
</body>
</html>